import { http } from '@/utils/http'
import type { FinanceRecord, FinanceRecordQuery, FinanceStatistics } from '@/types/finance'
import type { PageResult } from '@/types/global'

/**
 * 获取财务记录列表
 */
export const getFinanceRecordListAPI = (params: FinanceRecordQuery) => {
  return http<PageResult<FinanceRecord>>({
    method: 'GET',
    url: '/wechat/finance/records',
    data: params,
  })
}

/**
 * 添加财务记录
 */
export const addFinanceRecordAPI = (data: FinanceRecord) => {
  return http<FinanceRecord>({
    method: 'POST',
    url: '/wechat/finance/records/add',
    data,
  })
}
/**
 * 更新财务记录
 */
export const updateFinanceRecordAPI = (data: FinanceRecord) => {
  return http<FinanceRecord>({
    method: 'PUT',
    url: `/wechat/finance/records/update`,
    data,
  })
}

/**
 * 删除财务记录
 */
export const deleteFinanceRecordAPI = (id: string) => {
  return http({
    method: 'DELETE',
    url: `/wechat/finance/records/delete/${id}`,
  })
}

/**
 * 获取财务统计数据
 */
export const getFinanceStatisticsAPI = (params: {
  startDate?: string
  endDate?: string
  pageSize?: number
  pageNum?: number
}) => {
  return http<FinanceStatistics>({
    method: 'GET',
    url: '/wechat/finance/statistics',
    data: params,
  })
}
